#include<stdio.h>
main() {
	double x,sum;

	scanf_s("%lf", &x);
	sum = 3 * x * x * x * x * x + 2 * x * x * x * x - 5 * x * x * x - x * x + 7 * x - 6;
	printf("%g", sum);
	return 0;
}